home *** CD-ROM | disk | FTP | other *** search
/ Network PC / Network PC.iso / amiga utilities / communication / bbs / hydrabbsa8 / source / src.lha / utils / sendolm / Main.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-08  |  1.8 KB  |  102 lines

  1.  
  2. #include <exec/types.h>
  3. #include <exec/memory.h>
  4. #include <dos/dos.h>
  5. #include <clib/exec_protos.h>
  6. #include <clib/dos_protos.h>
  7. #include <clib/alib_protos.h>
  8.  
  9. #include <stdlib.h>
  10. #include <string.h>
  11. #include <stdio.h>
  12. #include <ctype.h>
  13. #include <time.h>
  14.  
  15. #ifdef __SASC
  16. int CXBRK(void) { return(0); }
  17. int _CXBRK(void) { return(0); }
  18. void chkabort(void) {}
  19. #endif
  20.  
  21. #include <HBBS/ANSI_Codes.h>
  22. #include <HBBS/Defines.h>
  23. #include <HBBS/types.h>
  24. #include <HBBS/structures.h>
  25. #include <HBBS/hbbscommon_protos.h>
  26. #include <HBBS/hbbscommon_pragmas.h>
  27. #include <HBBS/Hbbsnode_protos.h>
  28. #include <HBBS/Hbbsnode_pragmas.h>
  29.  
  30. struct Library *HBBSCommonBase=NULL;
  31.  
  32. struct BBSGlobalData *BBSGlobal=NULL;
  33.  
  34. static VOID cleanup(ULONG num)
  35. {
  36.   if (HBBSCommonBase)
  37.   {
  38.     HBBS_CleanUpCommon();
  39.     CloseLibrary (HBBSCommonBase);
  40.   }
  41.  
  42.   if (num) printf("Door Error = %d\n",num);
  43.  
  44.   exit(0);
  45. }
  46.  
  47. static VOID init(char *name)
  48. {
  49.   if(!(HBBSCommonBase = OpenLibrary("HBBSCommon.library",0)))
  50.   {
  51.     cleanup(1);
  52.   }
  53.  
  54.   if (!(HBBS_InitCommon()))
  55.   {
  56.     cleanup(2);
  57.   }
  58.  
  59.   SetProgramName(name);
  60. }
  61.  
  62. int main(int argc,char *argv[])
  63. {
  64.   LONG loop,tonode;
  65.   char outstr[2048];
  66.  
  67.   init("SendOLM");
  68.  
  69.   if (BBSGlobal=HBBS_GimmeBBS())
  70.   {
  71.     outstr[0]=0;
  72.     if (argc>=3)
  73.     {
  74.       if (sscanf(argv[1],"%ld",&tonode))
  75.       {
  76.         if (tonode>=0 && tonode < BBSGlobal->BBSNodes)
  77.         {
  78.           for (loop=2;loop<argc;loop++)
  79.           {
  80.             strcat(outstr,argv[loop]);
  81.             if (loop<argc-1) strcat(outstr," ");
  82.           }
  83.  
  84.           if (HBBS_SendOLM(0,"SendOLM",tonode,outstr,0))
  85.           {
  86.             puts("OLM Sent");
  87.           }
  88.           else
  89.           {
  90.             puts("OLM Failed - node my be busy, offline or there is no user-online");
  91.           }
  92.         }
  93.       }
  94.     }
  95.     else
  96.     {
  97.       puts("Invalid Parameters! usage: OLM <node> message...\r\n");
  98.     }
  99.   }
  100.   cleanup(0);
  101. }
  102.